Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
Convert to String a map similar to console output via console.log([...mapObject.entries()])

I have the following map:

  let mapObject = new Map();
  mapObject.set("one", "file1");
  mapObject.set("two", "file2");
  mapObject.set("three", "file3");

  console.log([...mapObject.entries()]);

and the console generates the following output:

[ [ 'one', 'file1' ], [ 'two', 'file2' ], [ 'three', 'file3' ] ]

I took this idea from this post, but this solution doesn't work if you add a string in the console statement:

console.log("This is a map: " + [...mapObject.entries()]);

it generates the following output instead:

This is a map: one,file1,two,file2,three,file3

which is less friendly to read. I would like in some how to have the same output I would obtain from: console.log([...mapObject.entries()]) but to be able to store it in a string for a general purpose. Is there a simple way to achieve it that works for google apps script?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use JSON.stringify:

let mapObject = new Map();
mapObject.set("one", "file1");
mapObject.set("two", "file2");
mapObject.set("three", "file3");

const res = JSON.stringify([...mapObject.entries()])

console.log("This is a map: " + res);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda